import React from 'react'
import { Link } from 'react-router-dom'
import { connect } from 'react-redux'
import { actions } from '../Header/store'
import styles from './style.css'


class Header extends React.Component {
    constructor(props){
        super(props);
        if(props.staticContext){
            props.staticContext.css.push(styles._getCss())
        }
    }
    render() {
        
        const { isLogin } = this.props;

        return (
            <div className={styles.box}>
                <Link to="/">首页</Link>
                {
                    isLogin
                    ?
                    (<div onClick={this.props.logOut}>退出登录</div>)
                    
                    :
                    (<div onClick={this.props.doLogin}>登录</div>)
                    
                }
            </div>
        )
    }
}


export default connect(
    state => {

        return {
            isLogin:state.head.isLogin
        }
    },
    {
        ...actions
    }
)(Header);